package com.rds.document.service.impl;

import com.rds.common.annotation.DataScope;
import com.rds.common.utils.DateUtils;
import com.rds.document.domain.RdaLibrary;
import com.rds.document.mapper.RdaLibraryMapper;
import com.rds.document.service.IRdaLibraryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文档库Service业务层处理
 *
 * @author rds
 * @date 2021-07-21
 */
@Service
public class RdaLibraryServiceImpl implements IRdaLibraryService
{
    @Autowired
    private RdaLibraryMapper rdaLibraryMapper;

    /**
     * 查询文档库
     *
     * @param id 文档库ID
     * @return 文档库
     */
    @Override
    public RdaLibrary selectRdaLibraryById(Long id)
    {
        return rdaLibraryMapper.selectRdaLibraryById(id);
    }

    @Override
    public RdaLibrary selectRdaLibraryByObjectId(String objectId) {
        return rdaLibraryMapper.selectRdaLibraryByObjectId(objectId);
    }

    /**
     * 查询文档库列表
     *
     * @param rdaLibrary 文档库
     * @return 文档库
     */
    @Override
    @DataScope(userStr = "read")
    public List<RdaLibrary> selectRdaLibraryList(RdaLibrary rdaLibrary)
    {
        return rdaLibraryMapper.selectRdaLibraryList(rdaLibrary);
    }

    /**
     * 新增文档库
     *
     * @param rdaLibrary 文档库
     * @return 结果
     */
    @Override
    public int insertRdaLibrary(RdaLibrary rdaLibrary)
    {
        rdaLibrary.setCreateTime(DateUtils.getNowDate());
        rdaLibrary.setModifyTime(DateUtils.getNowDate());
        return rdaLibraryMapper.insertRdaLibrary(rdaLibrary);
    }

    /**
     * 修改文档库
     *
     * @param rdaLibrary 文档库
     * @return 结果
     */
    @Override
    public int updateRdaLibrary(RdaLibrary rdaLibrary)
    {
        rdaLibrary.setModifyTime(DateUtils.getNowDate());
        return rdaLibraryMapper.updateRdaLibrary(rdaLibrary);
    }

    /**
     * 批量删除文档库
     *
     * @param ids 需要删除的文档库ID
     * @return 结果
     */
    @Override
    public int deleteRdaLibraryByIds(Long[] ids)
    {
        return rdaLibraryMapper.deleteRdaLibraryByIds(ids);
    }

    /**
     * 删除文档库信息
     *
     * @param id 文档库ID
     * @return 结果
     */
    @Override
    public int deleteRdaLibraryById(Long id)
    {
        return rdaLibraryMapper.deleteRdaLibraryById(id);
    }
}
